<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:template name="noLongWords">
 <xsl:param name="text"/>
 <xsl:param name="limit"/>
 <xsl:param name="cc"/>
 <xsl:choose>
   <xsl:when test="$cc &lt; 0">
   	...
	</xsl:when>
   <xsl:when test="string-length(substring-before($text,' ')) &gt; 0 and string-length(substring-before($text,' ')) &lt; $limit">
<xsl:value-of select="substring-before($text,' ')"/>&#32;<xsl:if test="string-length(substring-after($text,' ')) &gt; 0"><xsl:call-template name="noLongWords"><xsl:with-param name="text" select="substring-after($text,' ')"/><xsl:with-param name="limit" select="$limit"/><xsl:with-param name="cc" select="$cc - string-length(substring-before($text,' '))"/></xsl:call-template></xsl:if>
	</xsl:when>
   <xsl:when test="(string-length(substring-before($text,' ')) = 0)">
<xsl:value-of select="substring($text,1,$limit)"/>&#32;<xsl:if test="string-length(substring($text,$limit)) &gt; 0"><xsl:call-template name="noLongWords"><xsl:with-param name="text" select="substring($text,$limit)"/><xsl:with-param name="limit" select="$limit"/><xsl:with-param name="cc" select="$cc - string-length(substring($text,1,$limit))"/></xsl:call-template></xsl:if>
	</xsl:when>
   <xsl:when test="(string-length($text) &gt; $limit ) or string-length(substring-before($text,' ')) &gt; $limit">
<xsl:value-of select="substring($text,1,$limit)"/>&#32;<xsl:if test="string-length(substring($text,$limit )) &gt; 0"><xsl:call-template name="noLongWords"><xsl:with-param name="text" select="substring($text,$limit )"/><xsl:with-param name="limit" select="$limit"/><xsl:with-param name="cc" select="$cc - string-length(substring($text,1,$limit))"/></xsl:call-template></xsl:if>
	</xsl:when>
 </xsl:choose>
</xsl:template>

<xsl:template name="blt">
 <xsl:param name="text"/>
 <xsl:choose>
   <xsl:when test="contains($text,'&#60;')">
     <xsl:value-of select="substring-before($text,'&#60;')"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="$text"/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template name="blf">
 <xsl:param name="text"/>
 <xsl:choose>
   <xsl:when test="contains($text,'&#10;')">
     <xsl:value-of select="substring-before($text,'&#10;')"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="$text"/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template name="sp2br">
 <xsl:param name="text"/>
 <xsl:choose>
   <xsl:when test="contains($text,'&#32;')">
     <xsl:value-of select="substring-before($text,'&#32;')"/>
     <br/>
     <xsl:call-template name="sp2br">
       <xsl:with-param name="text">
         <xsl:value-of select="substring-after($text,'&#32;')"/>
       </xsl:with-param>
     </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="$text"/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:include href='../xsl.include.main.xsl'/>

<xsl:template match="forum">

<table class="fbox" border="0" cellspacing="0" cellpadding="5" width="100%">
<tr>
<td>
	<div style="border-bottom:1px dashed #BBBDC1;padding-bottom:5px;" class="body"><b><xsl:value-of select="@title" disable-output-escaping="yes"/></b>
		&#160;
		<span class="b10b">(
		<nobr>
		<xsl:call-template name="user">
			<xsl:with-param name="status" select="@uStatus"/>
			<xsl:with-param name="sexid" select="@sexid"/>
			<xsl:with-param name="certified" select="@certified"/>
			<xsl:with-param name="userid" select="@ownerid"/>
			<xsl:with-param name="nick" select="@nick"/>
		</xsl:call-template>
		</nobr>
		)</span>

		<div class="b10b" style="padding-top:2px;padding-bottom:2px;">
		<xsl:value-of select="@descr" disable-output-escaping="yes"/>
		</div>
	</div>

	<div style="padding-bottom:0px;padding-top:5px; text-align:right;">
	<xsl:choose>
		<xsl:when test='/forum/@logged and /forum/@isbaddie = 1'>
			<nobr><form style="display:inline;" action="/post2forum.aspx" method="get">
			<input type="hidden" name="forum_id" value="{@ID}"/>
			<input style="width:50px;" class="b10b" type="submit" value="scrivi" disabled="true"/>
			</form>
			<xsl:choose>
				<xsl:when test='@added = 0'>
					<form style="padding-left:5px; display:inline;" action="/forums/myforums.aspx" method="get">
					<input type="hidden" name="forumid" value="{@ID}"/>
					<input type="hidden" name="todo" value="ADD"/>
					<input style="" class="b10b" type="submit" value="aggiungi ai tuoi forum"  disabled="true"/>
					</form>
				</xsl:when>
				<xsl:otherwise>
					<input style="" class="b10b" type="submit" value="aggiungi ai tuoi forum" disabled="true"/>
				</xsl:otherwise>
			</xsl:choose>
			</nobr>
		</xsl:when>
		<xsl:when test='/forum/@logged'>
			<nobr><form style="display:inline;" action="/post2forum.aspx" method="get">
			<input type="hidden" name="forum_id" value="{@ID}"/>
			<input style="width:50px;" class="b10b" type="submit" value="scrivi"/>
			</form>
			<xsl:choose>
				<xsl:when test='@added = 0'>
					<form style="padding-left:5px; display:inline;" action="/forums/myforums.aspx" method="get">
					<input type="hidden" name="forumid" value="{@ID}"/>
					<input type="hidden" name="todo" value="ADD"/>
					<input style="" class="b10b" type="submit" value="aggiungi ai tuoi forum"/>
					</form>
				</xsl:when>
				<xsl:otherwise>
					<input style="" class="b10b" type="submit" value="aggiungi ai tuoi forum" disabled="true"/>
				</xsl:otherwise>
			</xsl:choose>
			</nobr>
		</xsl:when>
		<xsl:otherwise>
			<nobr><input type="submit" value="scrivi" disabled="true"/></nobr>
			<div class="b10b">(Per scrivere devi loggarti.)</div>
		</xsl:otherwise>
	</xsl:choose>
	</div>
</td>
</tr>

<xsl:for-each select="row[@public!=3]">
<tr>
<td style="border-top: 1px solid #BBBDC1;border-bottom: 1px solid #BBBDC1; background: white;">
	
	<div style="border-bottom:1px dashed gray; width:100%; word-wrap: break-word; padding-top:10px; padding-bottom:10px;" valign="top">
	<xsl:choose>
		<xsl:when test="@public=2">
			<b>Messaggio cancellato!</b>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="@text" disable-output-escaping="yes"/>
		</xsl:otherwise>
	</xsl:choose>
	</div>

			<div style="padding-top:5px;" class="body9" valign="top">
			<div style="color:gray;float:right;">(
			<xsl:call-template name="ggmmaahhmm">
				<xsl:with-param name="time" select="@time"/>
				<xsl:with-param name="cr" select="0"/>
			</xsl:call-template>
			<a style="color:#666666;" href="forumReadMessage.aspx?forumid={/forum/@ID}&amp;msgid={@ID}&amp;forumStep={/forum/@forumStep}&amp;forumPage={/forum/@forumPage}">&#160;)</a>
			</div>

			<xsl:variable name="userid" select="@userid"/>
			<xsl:choose>
				<xsl:when test='count(/forum/onlineusers/freak/user[@userid = $userid])'>
				<img style="margin-left:10px;margin-top:2px;" src="/imgs/online.gif"/>
				</xsl:when>
				<xsl:otherwise>
				<img style="margin-left:10px;margin-top:2px;" src="/imgs/offline.gif"/>
				</xsl:otherwise>
			</xsl:choose>
			<nobr>
			<xsl:call-template name="user">
				<xsl:with-param name="status" select="@uStatus"/>
				<xsl:with-param name="sexid" select="@sexid"/>
				<xsl:with-param name="certified" select="@certified"/>
				<xsl:with-param name="userid" select="@userid"/>
				<xsl:with-param name="nick" select="@nick"/>
			</xsl:call-template>
			</nobr>

			</div>

</td></tr>
<tr><td style="height:5px;"></td></tr>
</xsl:for-each>

<tr><td style="padding:10px;" align="center">

		<xsl:variable name="addUrl">
		  <xsl:value-of select="'&amp;forumId='"/>
		  <xsl:value-of select="/forum/@ID"/>
		  <xsl:value-of select="'&amp;forumStep='"/>
		  <xsl:value-of select="/forum/@forumStep"/>
		</xsl:variable>

			<xsl:call-template name="browse-bar">
				<xsl:with-param name="page" 		select="@page"/>
				<xsl:with-param name="nrpages" 	select="@nrsteps"/>
				<xsl:with-param name="MyUrl" 		select="@MyUrl"/>
				<xsl:with-param name="varPage" 	select="'?forumPage='"/>
				<xsl:with-param name="addUrl" 	select="$addUrl"/>
		</xsl:call-template>




</td></tr>

</table>

</xsl:template>

</xsl:stylesheet>